﻿@model IEnumerable<BestQA.QueryService.DTOs.QuestionDTO>
@{
    ViewBag.Title = "问题列表";
}
<div ng-app="" ng-controller="questionController">
    <button class="btn btn-primary btn-lg" data-toggle="modal" ng-click="showNewPostDialog()">我要提问</button>
    <table class="table table-striped">
        <thead>
            <tr>
                <th width="52%" class="vertical-center">
                    标题
                </th>
                <th width="10%" class="text-center vertical-center">
                    提问人
                </th>
                <th width="10%" class="text-center vertical-center">
                    提问时间
                </th>
                <th width="10%" class="text-center vertical-center">
                    问题状态
                </th>
            </tr>
        </thead>
        <tbody>
            @foreach (var question in Model)
            {
                <tr>
                    <td class="vertical-center">
                        @Html.ActionLink(question.Title, "Detail", new { id = question.Id }, new { target = "_blank" })
                    </td>
                    <td class="text-center vertical-center">
                        @Html.ActionLink(question.UserId, "Index", new { userId = question.UserId })
                    </td>
                    <td class="text-center vertical-center">
                        @question.CreatedTime
                    </td>
                    <td class="text-center vertical-center">
                        "正常"
                    </td>
                </tr>
            }
        </tbody>
    </table>
    <div class="modal fade" id="float-box-newPost">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">说出你的问题</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="title" class="col-sm-2 control-label">标题</label>
                            <div class="col-sm-9">
                                <input type="text" maxlength="256" id="title" class="form-control" ng-model="newPost.title" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="content" class="col-sm-2 control-label">内容</label>
                            <div class="col-sm-9">
                                <textarea id="content" maxlength="1000" class="form-control" ng-model="newPost.content" rows="5"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="tag" class="col-sm-2 control-label">标签（用分号;隔开）</label>
                            <div class="col-sm-9">
                                <input id="tag" type="text" maxlength="256" id="subject" class="form-control" ng-model="newPost.tag" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-9">
                                <span class="error" ng-show="errorMsg != ''">{{errorMsg}}</span>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" ng-click="submitPost()">提交</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</div>
@section Scripts
{
    <script type="text/javascript" src="@Url.Content("~/content/controllers/question-controller.js")"></script>
}